package br.com.registrofinancas.util;

import java.util.Calendar;
import java.util.GregorianCalendar;
import java.util.Map;
import java.util.Set;
import java.util.Map.Entry;

import android.content.Context;

	public class GregorianCalendarUtil {
		
		public static boolean comparaDias(GregorianCalendar dia1, GregorianCalendar dia2){
			return (null != dia1 && null != dia2) 
					&&
					(
						dia1.equals(dia2) || 
						(
							dia1.get(Calendar.DAY_OF_MONTH) ==  dia2.get(Calendar.DAY_OF_MONTH)
							&&
							dia1.get(Calendar.MONTH) ==  dia2.get(Calendar.MONTH)
							&&
							dia1.get(Calendar.YEAR) ==  dia2.get(Calendar.YEAR)
						)
					);
		}
		
		public static String[] getDiasLocalizacao(Context contexto) {
			String [] retorno = new String [7];
			
			Map<String, Integer> dias = GregorianCalendar.getInstance().getDisplayNames(GregorianCalendar.DAY_OF_WEEK, GregorianCalendar.SHORT, contexto.getResources().getConfiguration().locale);
			Set<Entry<String, Integer>> descricao = dias.entrySet();
			
			for (Entry<String, Integer> entry : descricao) {
				retorno[entry.getValue() - 1] = entry.getKey();
			}
			
			return retorno;
		}		
}
